﻿using Slwy.Data.Entity.Interfaces;
using Slwy.FrameCore.Dependency;

namespace Slwy.EventBus.Interfaces
{
    public interface ISlwyEventBus : IScopeDependency
    {
        /// <summary>
        /// 发送一个事件
        /// </summary>
        /// <param name="routingKey"> 路由 key </param>
        /// <param name="data"> 数据 </param>
        /// <param name="delayTime"> 延迟毫秒数 </param>
        /// <param name="errMessage"> 发送失败返回消息 </param>
        /// <returns>成功或者失败</returns>
        bool SendEvent(string routingKey, object data, out string errMessage, long delayTime);

        /// <summary>
        /// 发送一个事件
        /// 该事件是基于事务执行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="repo"></param>
        /// <param name="routingKey"></param>
        /// <param name="data"></param>
        /// <param name="errMessage"></param>
        /// <param name="delayTime"></param>
        /// <returns></returns>
        bool SendEventTrans<T>(IBaseRepository<T> repo, string routingKey, object data, out string errMessage,
            long delayTime = 0)
            where T : class, new();
    }
}
